//
//  LocalizationTool.swift
//  SwiftDemo
//
//  Created by hfzhangzhang on 2018/7/11.
//  Copyright © 2018年 hfzhangzhang. All rights reserved.
//

import UIKit

class LocalizationTool: NSObject {

   static func setLanguage(langeuage: String) {
        if langeuage != "" {
            UserDefaults.standard.set(langeuage, forKey: "userLanguage")
            UserDefaults.standard.synchronize()
        }
    }
    static func getSystemLanguage() -> String
    {
        let languages = UserDefaults.standard.object(forKey: "AppleLanguages") as! Array<String>//获取系统支持的所有语言集合
        let preferredLanguage = languages[0]//集合第一个元素为当前语言
        return String(preferredLanguage)//若当前系统为英文，则返回en_US
    }
}

public func getAppStr(_ key: String) -> String
{
    let str = NSLocalizedString(key, tableName: "Localizable",value: "default", comment: "default")
    return str
}
